package com.lcj.showTheLove.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


import java.util.ArrayList;


@Configuration
@EnableSwagger2
public class SwaggerConfir {
    @Bean
    public Docket docket(){
        // 设置要显示swagger的环境

        // 判断当前是否处于该环境
        // 通过 enable() 接收此参数判断是否要显示

        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
                .enable(true)//开启Swagger
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.lcj.showTheLove.web.controller"))//配置扫描接口（从哪里扫描接口--过滤）
                //.apis(RequestHandlerSelectors.withMethodAnnotation(GetMapping.class))//扫描注解是GET请求的API
                //.apis(RequestHandlerSelectors.withMethodAnnotation(PostMapping.class))//扫描注解是post请求的API
                //.paths(PathSelectors.ant("/lcj/**"))//扫描/lcj下的所有请求的接口
                .build();
    }
    //可通过Apiinfo配置文档信息
    @Bean
    public ApiInfo apiInfo(){
        final Contact DEFAULT_CONTACT = new Contact("show the love", "", "1297474906@qq.com");
        return new ApiInfo("ShowTheLove",
                "LCJApi Documentation",
                "1.0",
                "urn:tos",
                DEFAULT_CONTACT,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList());
    }

    @Bean
    public Docket docket1(){
        return new Docket(DocumentationType.SWAGGER_2).groupName("group1");
    }
    @Bean
    public Docket docket2(){
        return new Docket(DocumentationType.SWAGGER_2).groupName("group2");
    }
    @Bean
    public Docket docket3(){
        return new Docket(DocumentationType.SWAGGER_2).groupName("group3");
    }

}

